package com.freesky.web.manager.remote.order;

import com.freesky.common.pojo.DataTablesResult;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.vo.VOItem;
import com.freesky.web.manager.remote.order.fallback.ItemRemoteFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = "emall-provider-zuul", fallback = ItemRemoteFallback.class)
public interface ItemRemote {
    String ZUUL_URL_PREFIX = "/mysevice/order";
    String URL_PREFIX = "/item";
    @GetMapping(value = ZUUL_URL_PREFIX + URL_PREFIX +  "/{itemId}")
    JSONResponse getItemById(@PathVariable(value = "itemId") String itemId);

    @GetMapping(value =  ZUUL_URL_PREFIX + URL_PREFIX + "/list")
    DataTablesResult getItemList(
            @RequestParam(value = "draw") int draw,
            @RequestParam(value = "start") int start,
            @RequestParam(value = "length") int length,
            @RequestParam(value = "cid") int cid,
            @RequestParam(value = "search[value]") String search,
            @RequestParam(value = "order[0][column]") int orderCol,
            @RequestParam(value = "order[0][dir]") String orderDir);

    @GetMapping(value =  ZUUL_URL_PREFIX + URL_PREFIX + "/listSearch")
    DataTablesResult getItemSearchList(
            @RequestParam(value = "draw") int draw,
            @RequestParam(value = "start")  int start,
            @RequestParam(value = "length") int length,
            @RequestParam(value = "cid") int cid,
            @RequestParam(value = "searchKey")  String searchKey,
            @RequestParam(value = "minDate") String minDate,
            @RequestParam(value = "maxDate") String maxDate,
            @RequestParam(value = "search[value]") String search,
            @RequestParam(value = "order[0][column]") int orderCol,
            @RequestParam(value = "order[0][dir]") String orderDir);

    @GetMapping(value =  ZUUL_URL_PREFIX + URL_PREFIX + "/count")
    DataTablesResult getAllItemCount();

    @PutMapping(value =  ZUUL_URL_PREFIX + URL_PREFIX + "/stop/{id}")
    JSONResponse stopItem(@PathVariable(value = "id") String id);

    @PutMapping(value =  ZUUL_URL_PREFIX + URL_PREFIX + "/start/{id}")
    JSONResponse startItem(@PathVariable(value = "id") String id);

    @DeleteMapping(value = ZUUL_URL_PREFIX + URL_PREFIX +  "/del/{ids}")
    JSONResponse deleteItem(@PathVariable(value = "ids") String[] ids);

    @PostMapping(value =  ZUUL_URL_PREFIX + URL_PREFIX + "/add")
    JSONResponse addItem(@RequestBody VOItem voItem);

    @PostMapping(value = ZUUL_URL_PREFIX + URL_PREFIX +  "/update/{id}")
    JSONResponse updateItem(@PathVariable(value = "id") String id, @RequestBody VOItem voItem);

}
